# 国战演练托管，效果不好
def start_GuoZhan():
    touch((314,452)) # 进入经典场
    sleep(1)
    touch((312,565))# 国战
    sleep(1)
    touch((1163,180))
    sleep(11)
    for i in range(16):
        touch((i*100,250),times=2)
        sleep(0.1)
    sleep(1)
    touch((1100,593))
    count = 0
    ST.FIND_TIMEOUT_TMP = 1
    while True:
        count+=1

        if count%10==0:
            if exists(Template(r"tpl1734453121734.png", threshold=0.85, record_pos=(-0.214, -0.182), resolution=(1600, 900))):
                sleep(1)
                touch((42,98),times=2)
                sleep(1)
                break
            if exists(Template(r"tpl1734457514682.png", record_pos=(0.094, 0.179), resolution=(1600, 900))):
                touch((957,784))
        while exists(Template(r"tpl1734452236121.png", threshold=0.85, record_pos=(-0.034, 0.088), resolution=(1600, 900))):
            touch((180,800))
            sleep(0.5)
            touch((740,595))
            sleep(0.5)
        touch((1100,593),times=2)
        sleep(1)
    touch((42,98),times=2)
    ST.FIND_TIMEOUT_TMP = 2
    sleep(1.5)

#   自动演武已出，手动演武已过时
def start_YanWu():
    touch(Template(r"tpl1734427799591.png", record_pos=(0.314, 0.141), resolution=(1600, 900)))
    sleep(1)

    if not exists(Template(r"tpl1734426588187.png", record_pos=(-0.351, 0.253), resolution=(1600, 900))):
        print("7.2：未解锁演武功能")
        touch((1550,60)) # 返回键
        sleep(1)
        return
    touch(Template(r"tpl1734426588187.png", record_pos=(-0.351, 0.253), resolution=(1600, 900)))
    sleep(1)
    touch((1413,295),times=2)
    sleep(1)
    # 前9场的位置
    position=[(525,410),(525,580),(525,750),
             (990,410),(990,580),(990,750),
             (1450,410),(1450,580),(1450,750)]
    for i in range(len(position)):
        print("7.2 T开始第"+str(i+1)+"场演武")
        count = 1
        while True:
            touch(position[i])
            sleep(1.5)
            a = exists(Template(r"tpl1734427315420.png", record_pos=(-0.001, 0.221), resolution=(1600, 900)))
            if not a:
                print("7.2 T第"+str(i+1)+"场演武胜利！")
                break
            if count >2:
                print("7.2 F第"+str(i+1)+"场演武的2次尝试均失败！结束该场次")
                break
            touch((790,800))#开战
            sleep(5)
            count+=1
            touch((1550,60)) # 返回键
            sleep(1)
            touch((1200,60))# 托管
            while not exists(Template(r"tpl1734427157124.png", threshold=0.85, record_pos=(-0.001, 0.249), resolution=(1600, 900))):
                continue
            if exists(Template(r"tpl1734428038718.png", record_pos=(0.001, -0.104), resolution=(1600, 900))):
                touch((560,590))
                sleep(1)
                touch((790,590))
                sleep(1)
                touch((1060,590))
                sleep(1)
                touch((842,828))
            else:
                touch((842,828),times=2)
            sleep(2)
    # 第10场
#     swipe((164,800),(164,255))
#     print("7.2 T开始第10场演武")
#     count = 1;
#     sleep(2)
#     while True:
#         touch((525,750))
#         a = exists(Template(r"tpl1734427315420.png", record_pos=(-0.001, 0.221), resolution=(1600, 900)))
#         if count >5:
#             print("7.2 F第10场演武的5次尝试均失败！结束该场次")
#             break
#         if not a:
#             print("7.2 第10场演武胜利！")
#             break
#         touch((790,800))#开战
#         sleep(5)
#         count+=1
#         touch((1550,60)) # 返回键
#         sleep(1)
#         touch((1200,60))# 托管
#         while not exists(Template(r"tpl1734427157124.png", threshold=0.85, record_pos=(-0.001, 0.249), resolution=(1600, 900))):
#             continue
#         if exists(Template(r"tpl1734428038718.png", record_pos=(0.001, -0.104), resolution=(1600, 900))):
#             touch((560,590))
#             sleep(1)
#             touch((790,590))
#             sleep(1)
#             touch((1060,590))
#             sleep(1)
#             touch((842,828))
#         else:
#             touch((842,828),times=2)
#         sleep(2)
    print("7.2 T结束9场演武！开始领取今日胜场奖励")
    touch((1160,215))
    sleep(1.5)
    touch((1300,215))
    sleep(1.5)
    touch((1450,215))
    sleep(1.5)
    touch((80,144),times=2)
    touch((1550,60)) # 返回键
    sleep(1.5)
    touch((1550,60)) # 返回键
    sleep(1)